class Solution:
    def isPerfectSquare(self, num: int) -> bool:
        min_num, max_num = -1, num + 1
        while max_num - min_num > 1:
            now = (min_num + max_num) // 2
            if now ** 2 == num:
                return True
            elif now ** 2 < num:
                min_num = now
            else:
                max_num = now
        return False


a = Solution()
print(a.isPerfectSquare(160))
print(a.isPerfectSquare(16))
print(a.isPerfectSquare(0))
print(a.isPerfectSquare(1))
